package com.kele.jucutils;

import java.util.concurrent.CountDownLatch;

/**
 * @author kele
 * @date 2021/10/11 15:23
 * @description CountDownLatch 计数
 */
public class CountDownLatchTest {
    public static void main(String[] args) throws InterruptedException {
        /**
         * 给定初始值
         */
        CountDownLatch countDownLatch = new CountDownLatch(7);
        for (int i = 0; i <7 ; i++) {
            new Thread(()->{
                System.out.println(Thread.currentThread().getName()+" : "+"out");
                countDownLatch.countDown();
            },String.valueOf(i)).start();
        }
        /**
         * 等待计数器归0，再向下执行
         */
        countDownLatch.await();
        System.out.println("close");


    }
}
